package com.atguigu.spring.controller;

import com.atguigu.spring.service.api.BookService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;

@Controller(value = "bigPigHello")
public class BookController {

//    @Autowired
//    @Qualifier("xxx")
    @Resource
    private BookService bookService;

    // 通过 @Value 注解从外部属性文件读取数据
    // ${外部属性文件中的key:默认值}
    @Value(value = "${atguigu.mes2sage:apple}")
    private String message;

    public void doSomething() {
        System.out.println("BookController doSomething");
        System.out.println("外部属性文件中的数据 message = " + message);
        bookService.doSomething();
    }

}
